package com.example.blog.config;import com.example.blog.common.AppVariable;import jakarta.servlet.http.HttpServletRequest;import jakarta.servlet.http.HttpServletResponse;import jakarta.servlet.http.HttpSession;import org.springframework.web.servlet.HandlerInterceptor;/** * 登陆拦截器 */public class LoginInterceptor implements HandlerInterceptor {    //登陆返回true,未登录返回false    @Override    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {        HttpSession session = request.getSession(false);        //验证session        if(session!=null && session.getAttribute(AppVariable.USER_SESSION_KEY) != null)        {            return true;        }        //未登录，跳转到登陆页面        response.sendRedirect("/login.html");        return false;    }}